<?php
$result = \frontend\service\ArticleService::getRightMessage();
$hotArticle =$result['hotArticle'];
$randomArticle =$result['randomArticle'];
$tags =$result['tagBubble'];
$color = ['#44698B','#e0104e','#3f10e0','#10bee0','#10e05f','#bbe010','#e09210','#e03210'];
?>
<div class="sidebar-widget">
    <div class="single-widget profile-widget box-shadow">
        <div class="widget-inner text-center">
            <div class="profile-img">
                <a href="#"><img src="/statics/images/default/user.jpg" alt="profile"></a>
            </div>
            <div class="profile-name">
                <h3><a href="javascript:;">周小甜</a></h3>
                <p>前端小菇凉</p>
            </div>
            <div class="social-media">
                <ul class="clearfix">
                    <li class="wechat">
                        <a href="javascript:;"><i class="fa fa-wechat"></i></a>
                        <div style="display: none">
                            <img src="/statics/images/default/weixin.jpg" alt="weixin">
                        </div>
                    </li>
                    <li><a href="https://gitee.com/ztlandscape" target="_blank"><i class="fa fa-git"></i></a></li>
                    <li><a href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&amp;email=zhoutian@zhituanbox.com" target="_blank"><i class="fa fa-envelope"></i></a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="single-widget search-widget box-shadow">
        <div class="widget-inner">
            <div class="search-from box-shadow">
                <input type="text" id="search" name="search" placeholder="Search">
                <button class="search-icon" id="header-search"><i class="fa fa-search"></i></button>
            </div>
        </div>
    </div>
    <div class="single-widget tag-widget box-shadow">
          <div class="widget-inner">
              <div class="widget-title">
                  <h2 class="public-title">标签列表</h2>
              </div>
                  <div id="tagInner" class="tagInner">
                      <ul>
                          <?php if (count($tags)):?>
                              <?php $flag=0;?>
                              <?php foreach ($tags as $key=>$item):?>
                                  <?php $flag++;?>
                                  <?php if($flag>=count($color)-1){$flag=0;}?>
                                <li><i class="fa fa-tag"  style="color:<?=$color[$flag]?>"></i><a href="<?=$item['tag_url']?>" target="_blank"><?=$item['tag_name']?><i>(<?=$item['article_total']?>)</i></a></li>
                              <?php endforeach;?>
                          <?php endif;?>
                      </ul>
                  </div>
          </div>
    </div>

    <div class="single-widget category-widget box-shadow">
        <div class="widget-inner">
            <div class="widget-title">
                <h2 class="public-title">热门文章</h2>
            </div>
            <div class="category-list">
                <ul>
                    <?php if (count($hotArticle['rows'])):?>
                        <?php foreach ($hotArticle['rows'] as $key=>$item):?>
                            <li>
                                <i class="fa fa-tint"></i>
                                <a href="<?=$item['link']?>">
                                    <font><?=$item['title']?></font>
                                    <span><?=$item['release_at']?></span>
                                </a></li>
                        <?php endforeach;?>
                    <?php endif;?>
                </ul>
            </div>
        </div>
    </div>

    <div class="single-widget recent-post-widget box-shadow">
        <div class="widget-inner">
            <div class="widget-title">
                <h2 class="public-title">推荐文章</h2>
            </div>
            <div class="recent-post-list">
                <?php if (count($randomArticle['rows'])):?>
                    <?php foreach ($randomArticle['rows'] as $key=>$item):?>
                        <div class="single-post">
                            <div class="posty-img">
                                <a href="<?=$item['link']?>"><img src="<?=$item['cover_image']?>" onerror="this.src='/statics/images/245X138.jpg'" alt="blog"></a>
                            </div>
                            <div class="post-title">
                                <h4><a href="<?=$item['link']?>"><?=$item['title']?></a></h4>
                                <p><?=$item['summary']?></p>
                            </div>
                        </div>
                    <?php endforeach;?>
                <?php endif;?>
            </div>
        </div>
    </div>
</div>
<?=$this->registerJs("
requirejs(['/statics/js/public/control.js?'+(new Date()).getTime()], function () {
        require(['right']);;
    });
",\yii\web\View::POS_END)?>